home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / grapdrvs / anim_xmt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-21  |  22.5 KB  |  690 lines

  1. /*****************************************************************************
  2. *   A motif interface to the animation controller.                 *
  3. *                                         *
  4. * Written by:  Haggay Dagan, Zvika Zilberman and Gershon Elber             *
  5. *                            Ver 0.1, Feb. 1995.  *
  6. *****************************************************************************/
  7.  
  8. #ifdef __hpux
  9. typedef char *caddr_t;           /* Awful kludge. Let me know of a better way. */
  10. #endif /* __hpux */
  11.  
  12. #include <X11/Xlib.h>
  13. #include <X11/Xutil.h>
  14. #include <X11/cursorfont.h>
  15. #include <X11/Xresource.h>
  16.  
  17. #include <Xm/MainW.h>
  18. #include <Xm/PushB.h>
  19. #include <Xm/ToggleB.h>
  20. #include <Xm/SelectioB.h>
  21. #include <Xm/RowColumn.h>
  22. #include <Xm/MessageB.h>
  23. #include <Xm/Label.h>
  24. #include <Xm/Scale.h>
  25. #include <Xm/Form.h>
  26.  
  27. #include <string.h>
  28. #include <math.h>
  29.  
  30. #include "irit_sm.h"
  31. #include "iritgrap.h"
  32. #include "xmtdrvs.h"
  33.  
  34. typedef enum {
  35.     FILE_NAME,
  36.     START_TIME,
  37.     FINAL_TIME
  38. } PromptOkTypes;
  39.  
  40. typedef enum {
  41.     DISMISS,
  42.     BACKWARD,
  43.     FORWARD
  44. } SingleOkTypes;
  45.  
  46. static Widget AnimationForm, Bounce, Origin, IntervalSlide,
  47.     StartButton, EndButton, Single, FileForm[3], StopMe,
  48.     SingleForm, IntervalLabel;
  49.  
  50. static void CreateSingle(Widget w);
  51. static void CreatePromptMessage(Widget w, int State);
  52. static void StopAnimationCB(void);
  53. static void SingleOkCB(Widget w, int State);
  54. static void PromptOkCB(Widget w, int State, XmSelectionBoxCallbackStruct *Cbs);
  55. static void TgButtonsCB(Widget w,int State);
  56. static void IntervalCB(Widget w);
  57. static void BeginCB(Widget w);
  58. static void CancelCB(void);
  59. static void StartTimeCB(void);
  60. static void FinishTimeCB(void);
  61.  
  62. /*****************************************************************************
  63. * DESCRIPTION:                                     M
  64. *   creates the main animation window                            M
  65. *                                         *
  66. * PARAMETERS:                                     M
  67. *   The shell Widget (top level shell)                          M
  68. *                                         *
  69. * RETURN VALUE:                                     M
  70. *   void                                     M
  71. *****************************************************************************/
  72. void CreateAnimation(Widget w)
  73. {
  74.     static char
  75.     *Name[4] = { "Origin", "Bounce", "Single", "ToFile" };
  76.     Arg arg[10];
  77.     Widget Button, Form, SubForm, label1;
  78.     int i;
  79.     char String[10], NewLabel[20]; 
  80.     XmString MotifString;
  81.  
  82.     AnimFindAnimationTime(&IGAnimation, IGGlblDisplayList);
  83.  
  84.     XtSetArg(arg[0], XmNfractionBase, 11);
  85.     XtSetArg(arg[1], XmNdefaultPosition, FALSE);
  86.     XtSetArg(arg[2], XmNwidth, 250);
  87.     XtSetArg(arg[3], XmNheight, 400);
  88.     AnimationForm = XmCreateFormDialog(w, "Animation", arg, 4);
  89.  
  90.     for(i = 0; i < 4; i++) {
  91.         Form = CreateSubForm(AnimationForm, 1 + i);
  92.         SubForm = XtVaCreateManagedWidget("submarin",
  93.                       xmFormWidgetClass,      Form,
  94.                       XmNleftAttachment,      XmATTACH_FORM,
  95.                       XmNrightAttachment,     XmATTACH_FORM,
  96.                       XmNfractionBase,       5,
  97.                       NULL);
  98.     Button = XtVaCreateManagedWidget(Name[i],     
  99.                      xmToggleButtonWidgetClass, SubForm, 
  100.                      XmNrightAttachment, XmATTACH_POSITION,
  101.                      XmNrightPosition,   3,
  102.                      XmNleftAttachment,  XmATTACH_POSITION,
  103.                      XmNleftPosition,    1,
  104.                      NULL);
  105.     if (i == 0)
  106.         Origin = Button;
  107.     else if (i == 1)
  108.         Bounce = Button;
  109.     else if (i == 2)
  110.         Single = Button;
  111.     XtAddCallback(Button, XmNarmCallback, (XTC) TgButtonsCB, (XTP) i);
  112.     }
  113.  
  114.     sprintf(NewLabel, "Interval (ms) %d", (int) (IGAnimation.Dt * 1000));
  115.     IntervalLabel = AddLabel(AnimationForm, NewLabel, 9); 
  116.     Form = CreateSubForm(AnimationForm, 8);  
  117.     SubForm = XtVaCreateManagedWidget("submarin",
  118.                       xmFormWidgetClass,  Form,
  119.                       XmNleftAttachment,  XmATTACH_FORM,
  120.                       XmNrightAttachment, XmATTACH_FORM,
  121.                       XmNfractionBase,    10,
  122.                       NULL);
  123.     IntervalSlide = XtVaCreateManagedWidget("slide",
  124.                         xmScaleWidgetClass, SubForm,
  125.                         XmNvalue,        333,
  126.                         XmNshowValue,    FALSE,
  127.                         XmNorientation,    XmHORIZONTAL,
  128.                         XmNminimum,      0,
  129.                         XmNrightAttachment, XmATTACH_POSITION,
  130.                         XmNrightPosition,    9,
  131.                         XmNleftAttachment,  XmATTACH_POSITION,
  132.                         XmNleftPosition,    1,
  133.                         XmNmaximum,        1000,
  134.                         NULL); 
  135.     XtAddCallback(IntervalSlide, XmNvalueChangedCallback,
  136.           (XTC) IntervalCB, (XTP)NULL);
  137.     Form = CreateSubForm(AnimationForm, 5);
  138.     SubForm = XtVaCreateManagedWidget("matrixOpFoundation",
  139.                       xmFormWidgetClass,  Form,
  140.                       XmNleftAttachment,  XmATTACH_FORM,
  141.                       XmNrightAttachment, XmATTACH_FORM,
  142.                       XmNfractionBase,    11,
  143.                       NULL);
  144.     MotifString = XmStringCreate("Start", XmSTRING_DEFAULT_CHARSET);    
  145.     label1 =  XtVaCreateManagedWidget("submarin1",
  146.                       xmLabelWidgetClass, SubForm,
  147.                       XmNlabelString,      MotifString,
  148.                       XmNleftAttachment,  XmATTACH_POSITION,
  149.                       XmNleftPosition,    1,
  150.                       XmNrightAttachment, XmATTACH_POSITION,
  151.                       XmNrightPosition,   5,
  152.                       NULL);
  153.     XmStringFree(MotifString);
  154.     MotifString = XmStringCreate("End", XmSTRING_DEFAULT_CHARSET);    
  155.     label1 =  XtVaCreateManagedWidget("submarin1",
  156.                       xmLabelWidgetClass, SubForm,
  157.                       XmNlabelString,      MotifString,
  158.                       XmNleftAttachment,  XmATTACH_POSITION,
  159.                       XmNleftPosition,    6,
  160.                       XmNrightAttachment, XmATTACH_POSITION,
  161.                       XmNrightPosition,   10,
  162.                       NULL);
  163.     XmStringFree(MotifString);  
  164.     Form = CreateSubForm(AnimationForm, 6);
  165.     SubForm = XtVaCreateManagedWidget("matrixFoundation",
  166.                       xmFormWidgetClass,  Form,
  167.                       XmNleftAttachment,  XmATTACH_FORM,
  168.                       XmNrightAttachment, XmATTACH_FORM,
  169.                       XmNfractionBase,    11,
  170.                       NULL);
  171.     StartButton = XtVaCreateManagedWidget("Start",
  172.                       xmPushButtonWidgetClass, SubForm, 
  173.                       XmNleftAttachment,  XmATTACH_POSITION,
  174.                       XmNleftPosition,    1,
  175.                       XmNrightAttachment, XmATTACH_POSITION,
  176.                       XmNrightPosition,   5,
  177.                       NULL);
  178.     sprintf(String, "%4.2f", IGAnimation.StartT);
  179.     ReplaceLabel(StartButton, String);
  180.     XtAddCallback(StartButton, XmNactivateCallback,
  181.           (XTC) StartTimeCB, (XTP) NULL);
  182.  
  183.     EndButton = XtVaCreateManagedWidget("End", 
  184.                       xmPushButtonWidgetClass,    SubForm, 
  185.                       XmNleftAttachment,   XmATTACH_POSITION,
  186.                       XmNleftPosition,     6,
  187.                       XmNrightAttachment,  XmATTACH_POSITION,
  188.                       XmNrightPosition,    10,
  189.                       NULL);
  190.     XtAddCallback(EndButton, XmNactivateCallback,
  191.           (XTC) FinishTimeCB, (XTP) NULL);
  192.     sprintf(String, "%4.2f", IGAnimation.FinalT);
  193.     ReplaceLabel(EndButton, String);
  194.     Form = CreateSubForm(AnimationForm, 10); 
  195.     SubForm = XtVaCreateManagedWidget("matrixOpFoundation",
  196.                       xmFormWidgetClass,   Form,
  197.                       XmNleftAttachment,   XmATTACH_FORM,
  198.                       XmNrightAttachment,  XmATTACH_FORM,
  199.                       XmNfractionBase,     11,
  200.                       NULL);
  201.     Button = XtVaCreateManagedWidget("Begin",
  202.                      xmPushButtonWidgetClass,     SubForm, 
  203.                      XmNleftAttachment,    XmATTACH_POSITION,
  204.                      XmNleftPosition,      1,
  205.                      XmNrightAttachment,   XmATTACH_POSITION,
  206.                      XmNrightPosition,     5,
  207.                      NULL);
  208.     XtAddCallback(Button, XmNactivateCallback,
  209.           (XTC) BeginCB, (XTP) NULL);
  210.  
  211.     Button = XtVaCreateManagedWidget("Dismiss",        /* Save Matrix button */
  212.                      xmPushButtonWidgetClass,     SubForm, 
  213.                      XmNleftAttachment,    XmATTACH_POSITION,
  214.                      XmNleftPosition,      6,
  215.                      XmNrightAttachment,   XmATTACH_POSITION,
  216.                      XmNrightPosition,     10,
  217.                      NULL);
  218.     XtAddCallback(Button, XmNactivateCallback,
  219.           (XTC) CancelCB, (XTP) NULL);
  220.  
  221.     /* Create the other sub windows. */
  222.     CreateSingle(w);
  223.     CreatePromptMessage(w, 0);
  224.     CreatePromptMessage(w, 1);
  225.     CreatePromptMessage(w, 2);
  226. }
  227.  
  228. /*****************************************************************************
  229. * DESCRIPTION:                                     *
  230. *   Create the single step window                         *
  231. *                                         *
  232. * PARAMETERS:                                     *
  233. *   w:   The shell Widget (top level shell)                       *
  234. *                                         *
  235. * RETURN VALUE:                                     *
  236. *   void.                                     *
  237. *****************************************************************************/
  238. static void CreateSingle(Widget w)
  239. {
  240.     static char 
  241.     *Name[3] = { "Dismiss", "Backward", "Forward" };
  242.     int i;
  243.     Arg arg[20];
  244.     Widget Button, SubForm;
  245.     XmString MotifString;
  246.  
  247.     MotifString = XmStringCreate("Single Step", XmSTRING_DEFAULT_CHARSET);
  248.     XtSetArg(arg[0], XmNdialogTitle, MotifString);
  249.     XtSetArg(arg[1], XmNfractionBase,1);
  250.     XtSetArg(arg[2], XmNdefaultPosition,FALSE);
  251.     XtSetArg(arg[3], XmNwidth,300 );
  252.     XtSetArg(arg[4], XmNheight,50 );
  253.     SingleForm = XmCreateFormDialog(w, "single", arg, 5);
  254.     SubForm = XtVaCreateManagedWidget("matrixOpFoundation",
  255.                       xmFormWidgetClass,  SingleForm,
  256.                       XmNleftAttachment,  XmATTACH_FORM,
  257.                       XmNrightAttachment, XmATTACH_FORM,
  258.                       XmNfractionBase,    3,
  259.                       NULL);
  260.  
  261.     for (i = 0; i < 3; i++) {
  262.     Button = XtVaCreateManagedWidget(Name[i],        
  263.             xmPushButtonWidgetClass,     SubForm,
  264.             XmNtopAttachment,           XmATTACH_POSITION,
  265.             XmNtopPosition,                0,
  266.             XmNbottomAttachment,           XmATTACH_POSITION, 
  267.             XmNbottomPosition,            2,
  268.             XmNleftAttachment,           XmATTACH_POSITION,
  269.             XmNleftPosition,            i,
  270.             XmNrightAttachment,          XmATTACH_POSITION,
  271.             XmNrightPosition,            i + 1,
  272.             NULL);
  273.     XtAddCallback(Button, XmNactivateCallback, (XTC) SingleOkCB, (XTP) i);
  274.     }
  275. }
  276.  
  277. /*****************************************************************************
  278. * DESCRIPTION:                                     *
  279. *   Creates a prompt dialog with message.                     *
  280. *                                         *
  281. * PARAMETERS:                                     *
  282. *   w:      The shell Widget (top level shell)                          *
  283. *   State:  Determines which one of the prompt dialogs                  *
  284. *                                         *
  285. * RETURN VALUE:                                     *
  286. *   void                                     *
  287. *****************************************************************************/
  288. static void CreatePromptMessage(Widget w, int State)
  289. {
  290.     static char *
  291.     Title[3] ={ "Enter file name",
  292.             "Enter start time",
  293.             "Enter finish time" };
  294.     Arg args[3];
  295.     XmString MotifString;
  296.  
  297.     MotifString = XmStringCreate(Title[State], XmSTRING_DEFAULT_CHARSET);
  298.     XtSetArg(args[0], XmNselectionLabelString, MotifString);
  299.     FileForm[State] = (Widget) XmCreatePromptDialog(w, "File Form", args, 1);
  300.  
  301.     XmStringFree(MotifString);
  302.     XtAddCallback(FileForm[State], XmNokCallback,
  303.           (XTC) PromptOkCB, (XTP) State);
  304.     if (!State) {
  305.     MotifString = XmStringCreateSimple("Stop it");
  306.     XtSetArg(args[0], XmNcancelLabelString, MotifString);
  307.     StopMe = (Widget) XmCreateWorkingDialog(w, "Stop it", args, 1);
  308.     XtUnmanageChild(XmMessageBoxGetChild(StopMe, XmDIALOG_OK_BUTTON));
  309.     XtUnmanageChild(XmMessageBoxGetChild(StopMe, XmDIALOG_HELP_BUTTON));
  310.     XtAddCallback(StopMe, XmNcancelCallback,
  311.               (XTC) StopAnimationCB, (XTP) NULL);
  312.     XmStringFree(MotifString);
  313.     }
  314. }
  315.  
  316. /*****************************************************************************
  317. * DESCRIPTION:                                     *
  318. *   Stops the animation process using an async. event.                 *
  319. *                                         *
  320. * PARAMETERS:                                     *
  321. *   None                                     *
  322. *                                         *
  323. * RETURN VALUE:                                     *
  324. *   void                                     *
  325. *****************************************************************************/
  326. static void StopAnimationCB(void)
  327. {
  328.     IGAnimation.StopAnim = TRUE;
  329. }
  330.  
  331. /*****************************************************************************
  332. * DESCRIPTION:                                                               M
  333. *   Should we stop this animation? Senses the event queue of X.              M
  334. *                                                                            *
  335. * PARAMETERS:                                                                M
  336. *   Anim:     The animation to abort.                                        M
  337. *                                                                            *
  338. * RETURN VALUE:                                                              M
  339. *   int:      TRUE if we needs to abort, FALSE otherwise.                    M
  340. *                                                                            *
  341. * KEYWORDS:                                                                  M
  342. *   AnimCheckInterrupt                                                       M
  343. *****************************************************************************/
  344. int AnimCheckInterrupt(AnimationStruct *Anim)
  345. {
  346.     XEvent Event;
  347.     Display
  348.     *XDpy = XtDisplay(IGTopLevel);
  349.  
  350.     XFlush(XDpy);
  351.     XmUpdateDisplay(IGTopLevel);
  352.     while (XCheckMaskEvent(XDpy,
  353.                ButtonPressMask |
  354.                ButtonReleaseMask |
  355.                ButtonMotionMask |
  356.                PointerMotionMask |
  357.                KeyPressMask |
  358.                KeyReleaseMask,
  359.                &Event))
  360.     XtDispatchEvent(&Event);
  361.  
  362.     if (Anim ->StopAnim)
  363.     fprintf(stderr, "\nAnimation was interrupted by the user.\n");
  364.  
  365.     return Anim -> StopAnim;
  366. }
  367.  
  368. /*****************************************************************************
  369. * DESCRIPTION:                                     *
  370. *   Callback that deals with the single window Buttons                 *
  371. *                                         *
  372. * PARAMETERS:                                     *
  373. *   w:      The single widget                                  *
  374. *   State:  Determines whic Button was pressed.                      *
  375. *                                         *
  376. * RETURN VALUE:                                     *
  377. *   void                                     *
  378. *****************************************************************************/
  379. static void SingleOkCB(Widget w, int State)
  380. {
  381.     switch (State) {
  382.         case DISMISS:
  383.         XtUnmanageChild(SingleForm);
  384.         break;
  385.     case BACKWARD:
  386.         if (IGAnimation.RunTime - IGAnimation.Dt >=
  387.                     IGAnimation.StartT)
  388.         IGAnimation.RunTime -= IGAnimation.Dt;
  389.         else
  390.         IGAnimation.RunTime = IGAnimation.StartT;
  391.  
  392.         AnimDoSingleStep(&IGAnimation, IGGlblDisplayList);
  393.         break;
  394.     case FORWARD:
  395.         if (IGAnimation.RunTime + IGAnimation.Dt <=
  396.                     IGAnimation.FinalT)
  397.         IGAnimation.RunTime += IGAnimation.Dt;
  398.         else
  399.         IGAnimation.RunTime = IGAnimation.FinalT;
  400.  
  401.         AnimDoSingleStep(&IGAnimation, IGGlblDisplayList);
  402.         break;
  403.         default:
  404.         fprintf(stderr, "Mistake at SingleOkCB\n");
  405.     }
  406.  
  407. /*****************************************************************************
  408. * DESCRIPTION:                                     *
  409. *   Handler for the OK Button on a prompt dialog.                 *
  410. *                                         *
  411. * PARAMETERS:                                     *
  412. *   w:      The prompt dialog                                  *
  413. *   State:  Determines which one of the prompt dialogs                  *
  414. *   Cbs:    Event info.                                 *
  415. *                                         *
  416. * RETURN VALUE:                                     *
  417. *   void                                     *
  418. *****************************************************************************/
  419. static void PromptOkCB(Widget w, int State, XmSelectionBoxCallbackStruct *Cbs)
  420. {
  421.     char *String;
  422.     XmStringGetLtoR(Cbs -> value, XmSTRING_DEFAULT_CHARSET, &String); 
  423.  
  424.     switch (State) { 
  425.         case FILE_NAME: 
  426.         strcpy(IGAnimation.BaseFileName, String);
  427.         break;
  428.     case START_TIME: 
  429.         IGAnimation.StartT = atof(String);
  430.         ReplaceLabel(StartButton, String);
  431.         break; 
  432.     case FINAL_TIME: 
  433.         IGAnimation.FinalT = atof(String);
  434.         ReplaceLabel(EndButton, String);
  435.         break;
  436.     }
  437. }
  438.  
  439. /*****************************************************************************
  440. * DESCRIPTION:                                     *
  441. *   Handler for the toggle Button on a prompt dialog.                 *
  442. *                                         *
  443. * PARAMETERS:                                     *
  444. *   w:      the animation window                              *
  445. *   State:  Determines which one of the toggle Buttons has changed         *
  446. *                                         *
  447. * RETURN VALUE:                                     *
  448. *   void                                     *
  449. *****************************************************************************/
  450. static void TgButtonsCB(Widget w,int State)
  451. {
  452.     switch (State) {
  453.     case 0:
  454.         XmToggleButtonSetState(Bounce, FALSE, FALSE);
  455.         XmToggleButtonSetState(Single, FALSE, FALSE);
  456.         break;
  457.     case 1:
  458.         XmToggleButtonSetState(Origin, FALSE, FALSE);
  459.         XmToggleButtonSetState(Single, FALSE, FALSE);
  460.         break;
  461.     case 2:
  462.         XmToggleButtonSetState(Bounce, FALSE, FALSE);
  463.         XmToggleButtonSetState(Origin, FALSE, FALSE);
  464.         break;
  465.     case 3:
  466.         IGAnimation.SaveAnimation = !IGAnimation.SaveAnimation;
  467.         break;
  468.     }  
  469.  
  470. /*****************************************************************************
  471. * DESCRIPTION:                                     *
  472. *   Handler for the interval slide.                         *
  473. *                                         *
  474. * PARAMETERS:                                     *
  475. *   w:    the interval slide Widget                         *
  476. *                                         *
  477. * RETURN VALUE:                                     *
  478. *   void                                     *
  479. *****************************************************************************/
  480. static void IntervalCB(Widget w)
  481. {
  482.     int Interval;
  483.     char String[20];
  484.  
  485.     XmScaleGetValue(w, &Interval);
  486.     IGAnimation.Dt = pow(10.0, 0.003 * Interval);
  487.     IGAnimation.Dt = ((int) IGAnimation.Dt) / 1000.0;
  488.     sprintf(String, "Interval (ms) %d", (int) (IGAnimation.Dt * 1000.0));
  489.     ReplaceLabel(IntervalLabel, String);
  490.  
  491. /*****************************************************************************
  492. * DESCRIPTION:                                     *
  493. *   Handler for the Begin button.                         *
  494. * Invokes saving window and/or single step window. If required, starts the   *
  495. * animation.                                     *
  496. *                                         *
  497. * PARAMETERS:                                     *
  498. *   None                                     *
  499. *                                         *
  500. * RETURN VALUE:                                     *
  501. *   void                                     *
  502. *****************************************************************************/
  503. static void BeginCB(Widget w)
  504. {
  505.     Position AnimationWindowX, AnimationWindowY;
  506.     Dimension AnimationWindowW;
  507.     int Interval;
  508.     char String[20];
  509.  
  510.     IGAnimation.StopAnim = FALSE;
  511.  
  512.     XmScaleGetValue(IntervalSlide, &Interval);
  513.     IGAnimation.Dt = pow(10.0, 0.003 * Interval);
  514.     IGAnimation.Dt = ((int) IGAnimation.Dt) / 1000.0;
  515.     sprintf(String, "Interval (ms) %d", (int) (IGAnimation.Dt * 1000.0));
  516.     ReplaceLabel(IntervalLabel, String);
  517.  
  518.     IGAnimation.BackToOrigin = XmToggleButtonGetState(Origin);
  519.     IGAnimation.TwoWaysAnimation = XmToggleButtonGetState(Bounce);
  520.     IGAnimation.SingleStep = XmToggleButtonGetState(Single);
  521.     XtVaGetValues(AnimationForm,
  522.           XmNwidth,    &AnimationWindowW,
  523.           XmNx,        &AnimationWindowX,
  524.           XmNy,        &AnimationWindowY,
  525.           NULL);
  526.  
  527.     if (IGAnimation.SaveAnimation) {
  528.     XtVaSetValues(FileForm[0],
  529.               XmNdefaultPosition, FALSE,
  530.               XmNx,          AnimationWindowX +
  531.                       AnimationWindowW,
  532.               XmNy,          AnimationWindowY + 100,
  533.               NULL);
  534.     XtManageChild(FileForm[0]);
  535.     }
  536.  
  537.     if (IGAnimation.SingleStep) {
  538.     XtVaSetValues(SingleForm,
  539.               XmNdefaultPosition, FALSE,
  540.               XmNx,          AnimationWindowX +
  541.                       AnimationWindowW,
  542.               XmNy,          AnimationWindowY + 50,
  543.               NULL);
  544.     XtManageChild(SingleForm);
  545.     }
  546.     else {
  547.     XtVaSetValues(StopMe,
  548.               XmNdefaultPosition, FALSE,
  549.               XmNx,          AnimationWindowX +
  550.                       AnimationWindowW,
  551.               XmNy,          AnimationWindowY + 100,
  552.               NULL);
  553.     XtManageChild(StopMe);
  554.     AnimDoAnimation(&IGAnimation, IGGlblDisplayList);
  555.     XtUnmanageChild(StopMe);
  556.     }
  557. }
  558.  
  559. /*****************************************************************************
  560. * DESCRIPTION:                                     *
  561. *   Close the animation window                             *
  562. *                                         *
  563. * PARAMETERS:                                     *
  564. *   None                                     *
  565. *                                         *
  566. * RETURN VALUE:                                     *
  567. *   void                                     *
  568. *****************************************************************************/
  569. static void CancelCB(void)
  570. {
  571.     XtUnmanageChild(AnimationForm);
  572.     if (XtIsManaged(SingleForm))
  573.         XtUnmanageChild(SingleForm);
  574. }
  575.  
  576. /*****************************************************************************
  577. * DESCRIPTION:                                     M
  578. *   Getting input values from the user.                         M
  579. *                                         *
  580. * PARAMETERS:                                     M
  581. *   None                                                      M
  582. *                                         *
  583. * RETURN VALUE:                                     M
  584. *   void                                      
  585. *****************************************************************************/
  586. void AnimationCB(void)
  587. {  
  588.     Position MainWindowX, MainWindowY;
  589.     Dimension MainWindowW;
  590.   
  591.     XtVaGetValues(IGTopLevel,
  592.           XmNwidth,    &MainWindowW,
  593.           XmNx,        &MainWindowX,
  594.           XmNy,        &MainWindowY,
  595.           NULL);
  596.  
  597.     XtVaSetValues(AnimationForm,
  598.           XmNdefaultPosition, FALSE,
  599.           XmNx,              MainWindowX + MainWindowW + 16,
  600.           XmNy,              MainWindowY,
  601.           NULL);
  602.     XtManageChild(AnimationForm);
  603. }
  604.                                     
  605. /*****************************************************************************
  606. * DESCRIPTION:                                     *
  607. *   Manages the "change start time " window.                     *
  608. *                                         *
  609. * PARAMETERS:                                     *
  610. *   None                                     *
  611. *                                         *
  612. * RETURN VALUE:                                     *
  613. *   void                                      *
  614. *****************************************************************************/
  615. static void StartTimeCB(void)
  616. {
  617.     Position MainWindowX, MainWindowY;
  618.     Dimension MainWindowW;
  619.     
  620.     XtVaGetValues(AnimationForm,
  621.           XmNwidth,    &MainWindowW,
  622.           XmNx,        &MainWindowX,
  623.           XmNy,        &MainWindowY,
  624.           NULL);
  625.  
  626.     XtVaSetValues(FileForm[START_TIME],
  627.           XmNdefaultPosition, FALSE,
  628.           XmNx,              MainWindowX + 40,
  629.           XmNy,              MainWindowY + 320,
  630.           NULL);
  631.     XtManageChild(FileForm[START_TIME]);
  632. }
  633.  
  634. /*****************************************************************************
  635. * DESCRIPTION:                                     *
  636. *   Manages the "change finish time" window.                     *
  637. *                                         *
  638. * PARAMETERS:                                     *
  639. *   None                                     *
  640. *                                         *
  641. * RETURN VALUE:                                     *
  642. *   void                                     *
  643. *****************************************************************************/
  644. static void FinishTimeCB(void)
  645. {
  646.     Position MainWindowX,MainWindowY;
  647.     Dimension MainWindowW;
  648.   
  649.     XtVaGetValues(AnimationForm,
  650.           XmNwidth,    &MainWindowW,
  651.           XmNx,        &MainWindowX,
  652.           XmNy,        &MainWindowY,
  653.           NULL);
  654.  
  655.     XtVaSetValues(FileForm[2],
  656.           XmNdefaultPosition, FALSE,
  657.           XmNx,              MainWindowX + 80,
  658.           XmNy,              MainWindowY + 350,
  659.           NULL);
  660.     XtManageChild(FileForm[2]);
  661. }
  662.  
  663. /*****************************************************************************
  664. * DESCRIPTION:                                                               M
  665. *   Adds a new label to an old widget.                       M
  666. *                                                                            *
  667. * PARAMETERS:                                                                M
  668. *   w:      Calling widget.                                           M
  669. *   Label:  New label.                                 M
  670. *                                                                            *
  671. * RETURN VALUE:                                                              M
  672. *   none                                                         M
  673. *                                                                            *
  674. * KEYWORDS:                                                                  M
  675. *   ReplaceLabel                                        M
  676. *****************************************************************************/
  677. void ReplaceLabel(Widget  w, char *NewLabel)
  678.     XmString LabelText;
  679.     Arg args[10];
  680.  
  681.     LabelText = XmStringCreate(NewLabel, "CharSet1");
  682.     XtSetArg(args[0], XmNlabelString, LabelText);
  683.     XtSetValues(w, args, 1);
  684.     XmStringFree(LabelText);
  685. }
  686.